//
//  FmdbAccess.h
//  ebook
//
//  Created by 吴超飞 on 16/3/6.
//  Copyright © 2016年 Moton. All rights reserved.
//

#import <Foundation/Foundation.h>
#import "FMDB.h"
#import "Bookmark.h"
#import "Book.h"
#import "ChapterContent.h"

//数据是否跟用户关联？
@interface FmdbAccess : NSObject

+ (instancetype)shareModel;

@property (strong, nonatomic, readwrite) FMDatabaseQueue *queue;

//@property (nonatomic, copy) NSString * dbPath;

//添加书签
-(BOOL)addBookmark:(Bookmark *)mark;
//删除书签
-(BOOL)removeBookmark:(Bookmark *)mark;
//是否存在书签
-(BOOL)isExistBookmark:(Bookmark *)mark;

//获取某本书的书签列表
-(void)getBookmarkOfBook:(NSString *)bookid complete:(void(^)(NSMutableArray *books))complete;

//记录上次浏览位置
-(BOOL)recordBooknode:(Bookmark *)mark;
//获取上次浏览位置
-(void)getRecordBooknode:(NSString *)bookid complete:(void(^)(Bookmark *booknode))complete;


/*
//记录推荐数据
-(BOOL)addRecommand:(NSArray *)books;
//获取推荐数据
-(void)getRecomandBooks:(void(^)(NSMutableArray *recommandList))complete;
//删除推荐
-(BOOL)removeRecommandBook:(Book *)book;
//清空推荐表
-(BOOL)removeAllRecommandBooks;
*/

//删除用户某本书的阅读节点（阅读位置）数据
-(BOOL)removeReadBooknode:(NSString *)bookid;

//阅读界面退出，更新bookcases表,force=YES;其他不需要插入数据的地方force=NO，不存在记录就不更新
-(BOOL)updateBook:(Book *)book forceUpdate:(BOOL)force;

//记录书架图书数据
-(BOOL)addBookcase:(NSArray *)books;
//获取书架图书数据
-(void)getBookcases:(void(^)(NSMutableArray *casebooks))complete;
//删除书架某一本图书
-(BOOL)removeBookcase:(NSString *)bookid;
//清空书架数据
-(BOOL)clearBookcase;


@end
